import Vue from 'vue'
// import VCharts from 'v-charts'
import App from './App'

// Vue.use(VCharts)

import cuCustom from './common/colorui/components/cu-custom.vue'
Vue.component('cu-custom',cuCustom)
import MescrollUni from "./components/mescroll-uni/mescroll-uni.vue"
Vue.component('mescroll-uni', MescrollUni)

/* 表单校验 */
import $formValider from './utils/validate.js'

Vue.prototype.$formValider = $formValider 

Vue.filter("unixToDate",(unix, format)=>{
	if (!unix) return unix
	  let _format = format || 'yyyy-MM-dd hh:mm:ss'
	  const d = new Date(unix * 1000)
	  const o = {
	    'M+': d.getMonth() + 1,
	    'd+': d.getDate(),
	    'h+': d.getHours(),
	    'm+': d.getMinutes(),
	    's+': d.getSeconds(),
	    'q+': Math.floor((d.getMonth() + 3) / 3),
	    S: d.getMilliseconds()
	  }
	  if (/(y+)/.test(_format)) _format = _format.replace(RegExp.$1, (d.getFullYear() + '').substr(4 - RegExp.$1.length))
	  for (const k in o) if (new RegExp('(' + k + ')').test(_format)) _format = _format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
	  return _format
})

Vue.filter("formatPrice",(price)=>{
  if (typeof price !== 'number') return price
  return String(Number(price).toFixed(2)).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
})
Vue.filter('formatterSkuSpec',(sku)=>{
  if (!sku.spec_list || !sku.spec_list.length) return ''
  return sku.spec_list.map(spec => spec.spec_value).join(' - ')
})

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
	...App
})
app.$mount()
